package org.hackystat.ui.projectviewer.gwt.client.dataprovider;

import java.util.List;

import org.hackystat.ui.projectviewer.gwt.client.common.types.ProjectData;
import org.hackystat.ui.projectviewer.gwt.client.common.types.ProjectDevSummary;
import org.hackystat.ui.projectviewer.gwt.client.common.types.ProjectSummaryData;
import org.hackystat.ui.projectviewer.gwt.client.common.types.ProjectViewerProperties;

import com.google.gwt.user.client.rpc.RemoteService;

/**
 * The interface for the RPC server endpoint to get project data.
 *
 * @author Pavel Senin.
 */
public interface ProjectViewerDataProvider extends RemoteService {

  /**
   * Confirms Sensorbase host provided.
   *
   * @param host The host URL.
   * @return True if sensorbase contacted, false if not.
   */
  public Boolean confirmSensorbaseHost(String host);

  /**
   * Confirms DPD host provided.
   *
   * @param host The host URL.
   * @return True if sensorbase contacted, false if not.
   */
  public Boolean confirmDPDHost(String host);

  /**
   * Confirms Telemetry host provided.
   *
   * @param host The host URL.
   * @return True if telemetry contacted, false if not.
   */
  public Boolean confirmTelemetryHost(String host);

  /**
   * Authorizes client with sensorbase.
   *
   * @param host The sensorbase host.
   * @param user The user name.
   * @param password The password.
   * @return True if the client authorized or false if not.
   */
  public Boolean confirmUser(String host, String user, String password);

  /**
   * Reports list of all projects for authorized user.
   *
   * @param host The sensorbase host.
   * @param user The user name.
   * @param password The password.
   *
   * @return The list of registered projects as the list of names.
   */
  public List<String> getProjectIndex(String host, String user, String password);

  /**
   * Reports list of all invitations for authorized user.
   *
   * @param host The sensorbase host.
   * @param user The user name.
   * @param password The password.
   *
   * @return The list of all invitations.
   */
  public List<String> getInvitationsList(String host, String user, String password);

  /**
   * Creates new project record.
   *
   * @param host The sensorbase host.
   * @param user The user name.
   * @param password The password.
   * @param pd The project data to create.
   * @return True if successfully created the project, false if not.
   */
  public Boolean putProjectData(String host, String user, String password, ProjectData pd);

  /**
   * Reports project information.
   *
   * @param host The sensorbase host.
   * @param user The user name.
   * @param password The password.
   * @param projectName The project name.
   * @return The project record information.
   */
  public ProjectData getProjectData(String host, String user, String password, String projectName);

  /**
   * Deletes project record.
   *
   * @param host The sensorbase host.
   * @param user The user name.
   * @param password The password.
   * @param projectName The project name to delete.
   * @return True if successfully deleted project, false if not.
   */
  public Boolean deleteProject(String host, String user, String password, String projectName);

  /**
   * Retrieves configured properties from the server side user home. But in fact returns just
   * configured sensorbase host so far.
   *
   * @return The Sensorbase service host URL.
   */
  public ProjectViewerProperties getProjectViewerProperties();

  /**
   * Gets the actual sensor data from sensorbase.
   *
   * @param host The sensorbase host.
   * @param user The user name.
   * @param password The password.
   * @param startRow The row to start data set from.
   * @param maxRows The max amount of rows to fetch.
   * @param projectName The project name to get data for.
   * @param projectOwner The project owner.
   * @return The rows data.
   */
  public String[] getSensorData(String host, String user, String password, int startRow,
      int maxRows, String projectName, String projectOwner);

  /**
   * Registers new user with sensorbase.
   *
   * @param host The sensorbase host.
   * @param newUser The user e-mail.
   * @return The success of the action.
   */
  public Boolean registerUser(String host, String newUser);

  /**
   * Accepts invitation.
   *
   * @param host The sensorbase host.
   * @param user The user name.
   * @param password The password.
   * @param projectName The project name.
   * @return The success of the action.
   */
  public Boolean acceptInvitation(String host, String user, String password, String projectName);

  /**
   * Declines invitation.
   *
   * @param host The sensorbase host.
   * @param user The user name.
   * @param password The password.
   * @param projectName The project name.
   * @return The success of the action.
   */
  public Boolean declineInvitation(String host, String user, String password, String projectName);

  /**
   * Reports the exception code from app server side.
   *
   * @return The exception code.
   */
  public String getExceptionMessage();

  /**
   * Gets the project extendeded summary.
   *
   * @param sensorbaseHost The sensorbase host.
   * @param dpdHost The sensorbase host.
   * @param user The user name.
   * @param password The password.
   * @param projectId The project name.
   * @return The project data summary.
   */
  public ProjectSummaryData getProjectSummaryData(String sensorbaseHost, String dpdHost,
      String user, String password, String projectId);

  /**
   * Gets the project development data summary.
   *
   * @param telemetryHost The telemetry host.
   * @param user The user name.
   * @param password The password.
   * @param projectId The project name.
   * @param owner The project owner.
   * @return the project data development summary.
   */
  public ProjectDevSummary getProjectDevTimeData(String telemetryHost, String user,
      String password, String projectId, String owner);

  /**
   * Fires data download.
   *
   * @param sensorbaseHost The sensorbase host.
   * @param user The user name.
   * @param password The password.
   * @param projectId The project name.
   * @param sdtType The sdt type.
   * @return Success (true) if was able to fire download.
   */
  public Boolean fireDataDownload(String sensorbaseHost, String user, String password,
      String projectId, String sdtType);

}
